package me.ilich.piet.interpreter;

import me.ilich.piet.interpreter.StackState;
import junit.framework.TestCase;

public class StackStateTestCase extends TestCase {
	
	private StackState mStackState;
	
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		mStackState = new StackState();
	}
	
	public void testTurn1(){
		mStackState.setCC(StackState.LEFT);
		mStackState.turn();
		assertEquals(StackState.RIGHT, mStackState.getCC());
	}
	
	public void testTurn2(){
		mStackState.setCC(StackState.RIGHT);
		mStackState.turn();
		assertEquals(StackState.LEFT, mStackState.getCC());
	}
	
	public void testTurn3(){
		mStackState.setCC(StackState.LEFT);
		mStackState.turn(0);
		assertEquals(StackState.LEFT, mStackState.getCC());
	}
	
	public void testTurn4(){
		mStackState.setCC(StackState.LEFT);
		mStackState.turn(1);
		assertEquals(StackState.RIGHT, mStackState.getCC());
	}
	
	public void testTurn5(){
		mStackState.setCC(StackState.LEFT);
		mStackState.turn(2);
		assertEquals(StackState.LEFT, mStackState.getCC());
	}
	
	public void testTurn6(){
		mStackState.setCC(StackState.LEFT);
		mStackState.turn(3);
		assertEquals(StackState.RIGHT, mStackState.getCC());
	}	
	
	public void testRotate1(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotateClockwise();
		assertEquals(StackState.EAST, mStackState.getDP());
	}
	
	public void testRotate2(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotateAnticlockwise();
		assertEquals(StackState.WEST, mStackState.getDP());
	}
	
	public void testRotate3(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotate(0);
		assertEquals(StackState.NORTH, mStackState.getDP());
	}
	
	public void testRotate4(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotate(1);
		assertEquals(StackState.EAST, mStackState.getDP());
	}
	
	public void testRotate5(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotate(-1);
		assertEquals(StackState.WEST, mStackState.getDP());
	}
	
	public void testRotate6(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotate(2);
		assertEquals(StackState.SOUTH, mStackState.getDP());
	}
	
	public void testRotate8(){
		mStackState.setDP(StackState.NORTH);
		mStackState.rotate(-2);
		assertEquals(StackState.SOUTH, mStackState.getDP());
	}	

}
